package com.lxj.student_security.controller;

import com.lxj.student_security.common.CommonResult;
import com.lxj.student_security.entity.Daily;
import com.lxj.student_security.service.DailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.security.RolesAllowed;

@RestController
@RequestMapping("/daily")
public class DailyController {
    @Autowired
    private DailyService dailyService;
    @GetMapping("/findTeacher")
    public CommonResult findTeacher(){
        return dailyService.findTeacher();
    }
    @PostMapping("/save")
    public CommonResult save(Daily daily){
        return dailyService.save(daily);
    }
    @PostMapping("/findAll")
    public  CommonResult findAll(Daily daily){
        return dailyService.findAll(daily);
    }
    @PostMapping("/delete")
    public CommonResult delete(Integer[] id){
        return dailyService.delete(id);
    }
    @PostMapping("/edit")
    public CommonResult edit(Daily daily){
        return dailyService.edit(daily);
    }

    /**
     * 根据id改变一个提交状态，
     * @param id
     * @return
     */
    @PostMapping("/submit")
    public CommonResult submit(Integer id){
        return dailyService.submit(id);
    }
    @PostMapping("/findById")
    public CommonResult findById(Integer id){
        return dailyService.findById(id);
    }
    @PostMapping("/query")
    public CommonResult query(Integer id){
        return dailyService.query(id);
    }
    @PostMapping("/searchAll")
    public CommonResult searchAll(Daily daily){
        return dailyService.searchAll(daily);
    }
    @PostMapping("/audit")
    public CommonResult audit(Integer id){
        return dailyService.audit(id);
    }
}
